<template>
    <div class="addAppraisal">
      <el-form :model="ruleForm"
               :rules="rules"
               ref="ruleForm"
               label-width="130px"
               class="yuyi-ruleForm">
        <el-form-item label="项目名称" prop="name">
          <el-input size="small" v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="起止时间" prop="name">
          <div class="time-change">
            <el-date-picker
              v-model="ruleForm.value2"
              type="daterange"
              size="small"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
            <div class="">
              共100天
            </div>
          </div>
        </el-form-item>
        <el-form-item label="项目成员" prop="name">
          <el-select size="small" v-model="ruleForm.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="自定义流程" prop="name">
          <el-switch v-model="ruleForm.value"></el-switch>
        </el-form-item>
        <el-form-item label="审核人" prop="name">
          <el-select size="small" v-model="ruleForm.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目描述" prop="name">
          <el-input size="small"
                    v-model="ruleForm.name"
                    type="textarea"
                    :autosize="autosize"
                    maxlength="200"
                    show-word-limit></el-input>
        </el-form-item>
        <el-form-item label="">
          <el-button size="small" type="primary" @click="submitForm('ruleForm')">提交</el-button>
          <el-button size="small" @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
export default {
  name: 'addAppraisal',
  data () {
    return {
      autosize: {
        minRows: 4,
        maxRows: 6
      },
      value1: '',
      ruleForm: {
        name: '',
        value: '',
        value2: ''
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style lang="scss" scoped>
.addAppraisal{
  height: 100%;
  padding: 15px;
  background: #eaeaea;
  overflow-y: auto;
  .yuyi-ruleForm{
    width: 600px;
    margin: 0 auto;
    ::v-deep .el-range-separator{
      width: 60px !important;
    }
    .time-change{
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
}
</style>
